package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.wemedia.service.WmNewsService;
import com.heima.wemedia.service.impl.WmNewsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: zhk
 * @since: 2025/7/4
 */
@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {
    @Autowired
    private WmNewsService wmNewsService;
    @PostMapping("/list")
    public ResponseResult lists(@RequestBody WmNewsPageReqDto wmNewsPageReqDto){

        return wmNewsService.lists(wmNewsPageReqDto);

    }
    @PostMapping("submit")
    public ResponseResult submit(@RequestBody WmNewsDto wmNewsDto){
        wmNewsService.submit(wmNewsDto);
        return ResponseResult.okResult(null);

    }
    @GetMapping("/one/{id}")
    public ResponseResult one(@PathVariable Long id){
        WmNews wmNews = wmNewsService.selectOne(id);
        return ResponseResult.okResult(wmNews);

    }
}
